from ui_1jinru import Ui_MainWindow as jinru_Ui # 进入界面的库
from ui_2SingIn import Ui_MainWindow as singin_ui
from ui_3register import Ui_MainWindow as registerone_ui
from ui_4register import Ui_MainWindow as registertwo_ui
from ui_5main import Ui_MainWindow as main_ui
from ui_6punch_the_clock import Ui_MainWindow as punch_ui
from ui_7collection import Ui_MainWindow as collection_ui
from ui_8feedback import Ui_MainWindow as feedback_ui
from PyQt5.QtGui import QIcon
from PyQt5 import QtCore, QtWidgets
import sys

# 进入窗口
class jinruWindow(QtWidgets.QMainWindow,  jinru_Ui):
    # 登录页面跳转信号
    switch_singin = QtCore.pyqtSignal()
    def __init__(self):
        super(jinruWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.pushButton.clicked.connect(self.gosingin)
    def gosingin(self):
        self.switch_singin.emit()

# 登录窗口
class singinWindow(QtWidgets.QMainWindow,  singin_ui):
    switch_main = QtCore.pyqtSignal()  # 主界面跳转信号
    switch_registerone = QtCore.pyqtSignal()  # 注册页面_1跳转信号
    def __init__(self):
        super(singinWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.pushButton.clicked.connect(self.gomain)
        self.pushButton_2.clicked.connect(self.goregisterone)
    def gomain(self):
        self.switch_main.emit()
    def goregisterone(self):
        self.switch_registerone.emit()

# 注册窗口_1
class registeroneWindow(QtWidgets.QMainWindow,  registerone_ui):
    switch_registertwo = QtCore.pyqtSignal()  # 注册页面_1跳转信号
    switch_singin = QtCore.pyqtSignal()
    def __init__(self):
        super(registeroneWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.next_pushButton.clicked.connect(self.goregistertwo)
        self.propose_pushButton.clicked.connect(self.gosingin)
        self.propose_pushButton.clicked.connect(self.close)
    def goregistertwo(self):
        self.switch_registertwo.emit()
    def gosingin(self):
        self.switch_singin.emit()

# 注册窗口_2
class registertwoWindow(QtWidgets.QMainWindow,  registertwo_ui):
    def __init__(self):
        super(registertwoWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.propose_pushButton.clicked.connect(self.close)

# 主窗口
class mainWindow(QtWidgets.QMainWindow,  main_ui):
    switch_punch = QtCore.pyqtSignal()  # 考勤页面跳转信号
    switch_collection = QtCore.pyqtSignal()  # 信息采集页面跳转信号
    switch_feedback = QtCore.pyqtSignal()  # 意见反馈页面跳转信号
    def __init__(self):
        super(mainWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.pushButton_1.clicked.connect(self.gopunch)
        self.pushButton_2.clicked.connect(self.gocollection)
        self.pushButton_5.clicked.connect(self.gofeedback)
        self.pushButton_6.clicked.connect(self.close)
    def gopunch(self):
        self.switch_punch.emit()
    def gocollection(self):
        self.switch_collection.emit()
    def gofeedback(self):
        self.switch_feedback.emit()

# 考勤窗口
class punchWindow(QtWidgets.QMainWindow,  punch_ui):
    switch_homemain = QtCore.pyqtSignal()  # 回主页面跳转信号
    def __init__(self):
        super(punchWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.homeButton.clicked.connect(self.gohomemain)
        self.homeButton.clicked.connect(self.close)
    def gohomemain(self):
        self.switch_homemain.emit()

# 信息采集窗口
class collectionWindow(QtWidgets.QMainWindow,  collection_ui):
    switch_homemain = QtCore.pyqtSignal()  # 回主页面跳转信号
    def __init__(self):
        super(collectionWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.homeButton.clicked.connect(self.gohomemain)
        self.homeButton.clicked.connect(self.close)
    def gohomemain(self):
        self.switch_homemain.emit()

# 意见反馈窗口
class feedbackWindow(QtWidgets.QMainWindow,  feedback_ui):
    switch_homemain = QtCore.pyqtSignal()  # 回主页面跳转信号
    def __init__(self):
        super(feedbackWindow, self).__init__()
        self.setupUi(self)
        self.setWindowTitle("睿课人脸识别课堂考勤系统v2.0")
        self.setWindowIcon(QIcon('picture/Logo_2Max.png'))
        self.homepushButton.clicked.connect(self.gohomemain)
        self.homepushButton.clicked.connect(self.close)
    def gohomemain(self):
        self.switch_homemain.emit()

# 利用一个控制器来控制页面的跳转
class Controller:
    def __init__(self):
        pass
    # 跳转到进入窗口
    def show_jinru(self):
        self.jinru = jinruWindow()
        self.jinru.switch_singin.connect(self.show_singin)
        self.jinru.show()
    # 跳转到登录窗口, 注意关闭原页面
    def show_singin(self):
        self.singin =singinWindow()
        self.singin.switch_main.connect(self.show_main)
        self.singin.switch_registerone.connect(self.show_registerone)
        self.jinru.close()
        self.singin.show()

    # 跳转到注册窗口_1, 注意关闭原页面
    def show_registerone(self):
        self.registerone = registeroneWindow()
        self.registerone.switch_registertwo.connect(self.show_registertwo)
        self.registerone.switch_singin.connect(self.show_singin)
        self.singin.close()
        self.registerone.show()

    # 跳转到注册窗口_2, 注意关闭原页面
    def show_registertwo(self):
        self.registertwo = registertwoWindow()
        self.registerone.close()
        self.registertwo.show()

    # 跳转到主窗口, 注意关闭原页面
    def show_main(self):
        self.main = mainWindow()
        self.main.switch_punch.connect(self.show_punch)
        self.main.switch_collection.connect(self.show_collection)
        self.main.switch_feedback.connect(self.show_feedback)
        self.singin.close()
        self.main.show()

    # 跳转到考勤窗口, 注意关闭原页面
    def show_punch(self):
        self.punch = punchWindow()
        self.punch.switch_homemain.connect(self.show_main)
        self.main.close()
        self.punch.show()

    # 跳转到信息采集窗口, 注意关闭原页面
    def show_collection(self):
            self.collection = collectionWindow()
            self.collection.switch_homemain.connect(self.show_main)
            self.main.close()
            self.collection.show()

    # 跳转到信息采集窗口, 注意关闭原页面
    def show_feedback(self):
        self.feedback = feedbackWindow()
        self.feedback.switch_homemain.connect(self.show_main)
        self.main.close()
        self.feedback.show()

def main():
    app = QtWidgets.QApplication(sys.argv)
    controller = Controller() # 控制器实例,,
    controller.show_jinru() # 默认展示的进入页面

    sys.exit(app.exec_())

if __name__ == '__main__':
    main()







